package libra;

import java.util.Map;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Skywalking告警测试控制器
 */
@RestController
public class SwAlarmController {
	
	/**
	 * 慢应用请求
	 * isCreate不传默认为false
	 */
	@RequestMapping("slow")
	public Object slow( boolean isCreate ) throws Exception {
		if( isCreate ){
			Thread.sleep(2000);
		}
		return Map.of("method", "slow");
	}
	
	/**
	 * 异常应用请求
	 * isCreate不传默认为false
	 */
	@RequestMapping("ex")
	public Object ex( boolean isCreate ) throws Exception {
		if( isCreate ){
			int i = 1/0;		
		}
		return Map.of("method", "ex");
	}
	
	@RequestMapping("reviceWebHooks")
	public Object reviceWebHooks( @RequestBody String revice ) {
		System.out.println( revice );
		return Map.of("method", "reviceWebHooks");
	}
}
